<template>
  <div class="wrapper" ref="wrapper">
    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>

<script>
import BScroll from "better-scroll";
export default {
  name: "Scroll",
  components: {},
  props: {
    pullUpLoad: {
      type: Boolean,
      default: false,
    },
    probeType: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      scroll: null,
      isPullUpLoad: false,
      data: 30,
    };
  },
  mounted() {
    this.scroll = new BScroll(this.$refs.wrapper, {
      click: true,
      probeType: this.probeType,
      useTransition: true,
      observeDOM: true,
      pullUpLoad: this.pullUpLoad,
      mouseWheel: {
        speed: 20,
        invert: false,
        easeTime: 300,
      },
    });
    if (this.pullUpLoad == true) {
      this.scroll.on("pullingUp", () => {
        this.isPullUpLoad = true;
        setTimeout(() => {
          this.$emit("pullingUp");
          this.scroll.refresh();
        }, 500);
        this.scroll.finishPullUp();
        this.isPullUpLoad = false;
      });

      this.scroll.on("scroll", (position) => {
        this.$emit("scroll", position);
      });
    }
  },
  methods: {},
};
</script>

<style lang="css" scoped>
</style>